<?php

/**
 * @author Murat Cem YALIN <muratcem@gmail.com>
 * @copyright 2014 muratcem.com - walkerPHP.com
 * @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3
 * @version 1.0.1
 */

namespace core\table;


interface ITable{

    /**
     * resets all select fields and sets new columns
     * you can set $columns as string or array and also
     * like this: $columns = array(array($tablename1, $fieldname1), array($tablename2, $fieldname2), ...)
     * which should give SELECT tablename1.fieldname1, tablename2.fieldname2
     *
     * @param string|array $columns
     * @return $this
     */
    public function select($columns = array('*'));

    /**
     * add field to select
     * you can set $columns as string or array and also
     * like this: $columns = array(array($tablename1, $fieldname1), array($tablename2, $fieldname2), ...)
     * which should give SELECT tablename1.fieldname1, tablename2.fieldname2
     *
     * @param string|array $column
     * @return $this
     */
    public function add_select($column);

    /**
     * join tables
     *
     * @param string $table other table name
     * @param array $on array(main_table_fieldname, operator, other_table_fieldname)
     * @param string $type LEFT|RIGHT|INNER|OUTER|LEFT OUTER|RIGHT OUTER
     * @return $this
     */
    public function join($table, $on, $type);

    /**
     * adds AND where clause
     *
     * @param string $column
     * @param string $sign
     * @param string $value
     * @return $this
     */
    public function where($column, $sign, $value);

    /**
     * adds order by
     *
     * @param string $column
     * @param string $asc ASC|DESC
     * @return $this
     */
    public function order_by($column, $asc);

    /**
     * adds limit to query
     *
     * @param int $start
     * @param int $count
     * @return $this
     */
    public function limit($start, $count);

    /**
     * adds limit to query by calculating per page counts
     *
     * @param int $page
     * @param int $perPage
     * @return $this
     */
    public function getPage($page, $perPage = 10);

    /**
     * SELECT Query
     *
     * @return array
     */
    public function get();

    /**
     * insert set of data to table
     * array("fieldname" => "value")
     *
     * @param array $array
     * @return bool
     */
    public function insert(Array $array);

    /**
     * update records in table
     * array("fieldname" => "value")
     *
     * @param array $array
     * @return bool
     */
    public function update(Array $array);

    /**
     * delete record from table
     *
     * @return bool
     */
    public function delete();

    /**
     * this function is for getting total row count without limit after executed SQL
     *
     * @return integer
     */
    public function getTotalCount();
}







































